package com.by.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.by.bean.UserInfo;
import com.by.context.UserContext;
import com.by.entity.Member;
import com.by.entity.MemberAddress;
import com.by.mapper.MemberAddressMapper;
import com.by.mapper.MemberMapper;
import com.by.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;


@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {



    @Autowired
    MemberMapper memberMapper;

    @Autowired
    MemberAddressMapper memberAddressMapper;

    @Override
    public Member register(Member member) {
//        //        首先获取token中的用户信息
//        UserInfo info= UserContext.get();
//        UserContext.clear();
        Member existingMember = memberMapper.selectByUsername(member.getUsername());
        if (existingMember != null) {
            throw new IllegalArgumentException("用户名已存在");
        }
        memberMapper.insert(member);
        return member;
    }
}